<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<link href="./css/h-ui/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
	<link href="./css/index.css" rel="stylesheet" type="text/css" />
	<link href="./js/ymPrompt/skin/simple/ymPrompt.css" rel="stylesheet" type="text/css">

	<script src="./js/jquery.min.js"></script>
	<script src="./im/js/util.js"></script>
	<script src="./im/js/md5.js"></script>
	<script src="./js/ymPrompt/ymPrompt.js"></script>
</head>

<body>
	<div class="box">
		<div class="center_index">
			<div class="left_index">
				<img src="images/logo.png" />
			</div>
			<div class="right_index">
				<input type="text" id="username" placeholder="请输入用户名" onfocus="javascript:if(this.placeholder=='请输入用户名')this.placeholder='';"
				 onfocusout="javascript:if(this.placeholder=='')this.placeholder='请输入用户名';" />
				<input type="password" id="password" placeholder="请输入密码" onfocus="javascript:if(this.placeholder=='请输入密码')this.placeholder='';"
				 onfocusout="javascript:if(this.placeholder=='')this.placeholder='请输入密码';" />
				<a id="up">
					<li>进入系统</li>
				</a>
				<a id="a2">
					<li>重置</li>
				</a>
				<a id="a2">
					<li>修改密码</li>
				</a>
			</div>
		</div>
	</div>
	<script>
		localStorage.setItem("baseUrl", "http://211.149.205.33:8880");
		window.baseUrl = localStorage.getItem("baseUrl");
		$(document).ready(function () {

			$("#password").keypress(function (e) {
            if (e.which == 13) {
				document.getElementById("up").click();
            }	
		});

			$("#up").click(function () {
				var username = $("#username").val();
				var password = $("#password").val();
				if (isEmpty(username)) {
					alert("用户名为空!");
					return;
				}
				if (isEmpty(password)) {
					alert("密码为空!");
					return;
				}

				$.ajax({
					type: "POST",
					url: window.baseUrl + "/login",
					contentType: "application/x-www-form-urlencoded",
					data: {
						username: username,
						password: password,
						rememberMe:"1",
						userType: "2"
					},
					dataType: "json",
					async: false,
					success: function (data) {
						if (data.code == 0) {
							// setCookie('uid', data.data.account);
							// setCookie('sdktoken', MD5(password));
							// localStorage.setItem("account", username);
							// localStorage.setItem("doctorname", data.data.doctorname);
							// localStorage.setItem("doctorId", data.data.doctorId);
							// localStorage.setItem("Authorization", data.data.token);
							// localStorage.setItem(data.data.token, "1");
							
							setCookie('uid', data.data.imaccount);
							setCookie('sdktoken', data.data.token);
							localStorage.setItem("account", username);
							localStorage.setItem("doctorname", data.data.userName);
							localStorage.setItem("doctorId", data.data.userId);
							localStorage.setItem("sessionid", data.data.sessionId);
							window.location.href = './im/main.html';
						} else {
							alert(data.msg);
						}
					},
					error: function (data) {
						alert("网络错误,请重试.");
					}
				});

			});

			function isEmpty(obj) {
				if (typeof obj == "undefined" || obj == null || obj == "") {
					return true;
				} else {
					return false;
				}
			}
		})
	</script>
</body>

</html>